package com.example.easy.Controller;



import com.example.easy.Dto.Notice;
import com.example.easy.Dto.User;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Service.myservice.UserService;
import com.example.easy.Tools.ResultCode;
import com.example.easy.mapper.NoticeMapper;
import com.example.easy.mapper.UserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Scope("prototype")
@RestController
@Api(value = "Notice", description = "公告栏管理")
@RequestMapping(value = "/notice")

public class NoticeController {


    @Autowired
    NoticeServise noticeServise;


    @Autowired
    NoticeMapper noticeMapper;

    @ApiOperation(value = "增加公告", notes = "增加公告")
    @RequestMapping(value = "/insNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object insNotice(@RequestBody Notice notice) throws IOException {

        return ResultCode.SUCCESS.result(noticeServise.insNotice(notice));

    }

    @ApiOperation(value = "修改公告", notes = "修改公告")
    @RequestMapping(value = "/updateNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object updateNotice(@RequestBody Notice notice) throws IOException {

        return ResultCode.SUCCESS.result(noticeServise.updateNotice(notice));

    }

    @ApiOperation(value = "删除公告", notes = "删除公告")
    @RequestMapping(value = "/deleteNotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object deleteNotice(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(noticeServise.deleteNotice(number));

    }

    @ApiOperation(value = "查看公告", notes = "查看公告")
    @RequestMapping(value = "/selectnotice", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectnotice(@RequestBody int number) throws IOException {

        return ResultCode.SUCCESS.result(noticeServise.selectnotice(number));

    }

    @ApiOperation(value = "查看所有公告", notes = "查看所有公告")
    @RequestMapping(value = "/selectall", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object selectall() throws IOException {

        return ResultCode.SUCCESS.result(noticeServise.selectall());

    }

}
